Skip to content

Rest shape measure - #229

Merged
zfergus merged 13 commits into
ipc-sim:mainfrom
udaykusupati:rest_shape_measure
Nov 8, 2026
Merged

zfergus merged 13 commits into
ipc-sim:mainfrom
udaykusupati:rest_shape_measure

Conversation

@udaykusupati

@udaykusupati udaykusupati commented May 1, 2026 •

Copy link
Copy Markdown
Contributor

Description

For all the primitives, using quadrature on the rest shape instead of on the autodiff/differentiable parameters of the collision mesh. This feature is enabled by adding a use_rest_shape_measure parameter in SmoothParams
Fixes # (issue)

Type of change

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

How Has This Been Tested?

This was necessary for a 2D GCP case where spurious gradients appear when integrating on the deformation coordinates.
However, no explicit testing was done, except gradient visualization

Checklist

  • I have followed the project style guide
  • My code follows the clang-format style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@codecov

codecov Bot commented May 1, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.14286% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.86%. Comparing base (e7075aa) to head (328fec8).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/ipc/gcp/primitives/edge2.cpp 88.88% 3 Missing ⚠️
src/ipc/gcp/primitives/point2.cpp 97.67% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #229      +/-   ##
==========================================
+ Coverage   96.85%   96.86%   +0.01%     
==========================================
  Files         225      227       +2     
  Lines       22855    23035     +180     
  Branches     1587     1620      +33     
==========================================
+ Hits        22136    22313     +177     
- Misses        719      722       +3     
Flag Coverage Δ
unittests 96.86% <97.14%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@zfergus
zfergus requested a review from Copilot May 1, 2026 15:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds an option to use rest-shape (non-differentiated) quadrature measures for smooth-contact primitives to avoid spurious gradients from integrating over deformed collision mesh parameters.

Changes:

  • Introduces use_rest_shape_measure in SmoothContactParameters to toggle rest-shape quadrature weights.
  • Updates Point2/Point3/Edge2/Edge3 to use rest-shape length/area weights and to drop derivative contributions from the measure when enabled.
  • Refactors Face primitive evaluation to return rest-shape area (and zero derivatives) when enabled.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
src/ipc/smooth_contact/common.hpp Adds use_rest_shape_measure toggle to parameters.
src/ipc/smooth_contact/primitives/point3.hpp Stores a cached rest-shape quadrature weight for Point3.
src/ipc/smooth_contact/primitives/point3.cpp Computes/uses rest-shape Point3 weight; removes measure derivatives when enabled.
src/ipc/smooth_contact/primitives/point2.hpp Stores a cached rest-shape length measure for Point2.
src/ipc/smooth_contact/primitives/point2.cpp Passes a “measure” into point2 terms and switches between rest/deformed measures.
src/ipc/smooth_contact/primitives/face.hpp Changes Face evaluation API to instance methods and stores rest area.
src/ipc/smooth_contact/primitives/face.cpp Computes rest area; returns constant measure / zero derivatives when enabled.
src/ipc/smooth_contact/primitives/edge3.hpp Stores cached rest-shape squared edge length.
src/ipc/smooth_contact/primitives/edge3.cpp Uses rest/deformed squared-length weight and drops its derivatives when enabled.
src/ipc/smooth_contact/primitives/edge2.hpp Stores cached rest-shape edge length.
src/ipc/smooth_contact/primitives/edge2.cpp Returns rest length / zero derivatives when enabled.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/ipc/gcp/common.hpp Resolved
Comment thread src/ipc/gcp/primitives/point3.cpp Resolved
Comment thread src/ipc/gcp/primitives/face.hpp Resolved
Comment thread src/ipc/gcp/primitives/face.cpp Resolved
Comment thread src/ipc/gcp/primitives/face.cpp Resolved
Comment thread src/ipc/gcp/primitives/face.cpp Resolved
Comment thread src/ipc/gcp/primitives/point2.cpp Resolved
Comment thread src/ipc/gcp/primitives/point2.cpp Resolved
Comment thread src/ipc/gcp/primitives/point2.cpp Resolved
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@zfergus zfergus added enhancement New feature or request bug Something isn't working and removed enhancement New feature or request labels Sep 11, 2026
- Always compute and default-initialize the rest-shape measures
- Factor the Point2 measure selection into shared helpers
- Drop unused `d` parameter names in Face
@zfergus

zfergus commented Nov 8, 2026

Copy link
Copy Markdown
Member

Hi @udaykusupati, is this fix still relevant after the ESP changes? I updated it with main and resolved the Copilot comments. I can merge it after you give the go-ahead.

@zfergus
zfergus merged commit 5ff4857 into ipc-sim:main Nov 8, 2026
19 checks passed
@zfergus

zfergus commented Nov 8, 2026 •

Copy link
Copy Markdown
Member

This PR was merged by accident. I pushed the branch to main directly (after merging in the latest main and addressing the Copilot comments, plus adding a test for use_rest_shape_measure), and GitHub marked it as merged.

The changes will stay on main unless you say otherwise, @udaykusupati.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants